USE [NamaAlart]
GO

/****** Object:  StoredProcedure [dbo].[process_tag_id]    Script Date: 04/26/2009 22:02:42 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[process_tag_id]
@TagValue nvarchar(100)
AS
SET NOCOUNT ON
DECLARE @tmp bigint;

SET @tmp=(SELECT ID FROM Tags WHERE Value=@TagValue);
IF @tmp IS NOT NULL
	SELECT @tmp;
ELSE
BEGIN
	INSERT INTO Tags(Value) VALUES(@TagValue);
	SELECT CAST(SCOPE_IDENTITY() AS bigint);
END
SET NOCOUNT OFF


GO


